


<div class="admin-biaogelist">
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">

                <div class="layui-card-header">

                     <button class="layui-btn add">添加配置</button>
                    <button class="layui-btn edit">编辑配置</button>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-hide" id="userlist" lay-filter="userlist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<script>
    var info={};


    layui.use('table', function(){
        var table = layui.table;
        var $ = layui.$;
        table.render({
            elem: '#userlist'
            ,method:"post"
            ,url:baseurl+'/Customer/getconfiglist',
            page:true,
            id:'userlist'
            ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.code, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.list //解析数据列表
                };
            }
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,cellMaxWidth: 300
            ,cols: [[
                {type: 'radio', fixed: 'left',width:60},
                {align:'center', field:'id',  title: '序号',  }
                , {align:'center',field:'titel', title: '配置名称',sort: true}
                , {align:'center',field:'value', title: '配置值',sort: true}
                , {align:'center',field:'name', title: '配置代号',sort: true}

            ]]
        });



        $(".edit").click(function () {
            var checkStatus = table.checkStatus("userlist");
            var data = checkStatus.data;
            info=data[0];

            if(data.length>1 || data.length==0){
                layer.msg('必须先选择一个配置');
                return
            }
            xadmin.open("修改配置","/Customer/editeconfig",800,600);
        });


        $(".add").click(function () {
            xadmin.open("修改用户积分","/Customer/addconfig",800,600);
        });







        var $ = layui.$, active = {
            reload: function(){
                var username = $("input[name='username']").val();
                var loginName = $("input[name='phone']").val();
                var inc = $("input[name='inc']").val();

                /*var regtime= $("input[name='start']").val();
                var  regtime=regtime.split(" - ");*/

                var createTimeStart =$("input[name='start']").val();
                var createTimeEnd =$("input[name='end']").val();
                var frominc = $("input[name='frominc']").val();

                var id = $("input[name='userid']").val();

                var roleId = $("#view").val();


                //执行重载
                table.reload('userlist', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where:{
                        createTimeStart:createTimeStart,
                        createTimeEnd:createTimeEnd,
                        frominc:frominc,
                        inc:inc,
                        roleId:roleId,
                        name: username,
                        loginName: loginName,
                        id: id
                    }
                }, 'data');
            }
        };

        $('.layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });



</script>



